<%@ page import="java.util.List" %>
<%@ page import="cn.Grade" %>
<%@ page import="cn.Subject" %><%--
  Created by IntelliJ IDEA.
  User: oldliu
  Date: 2021-11-22
  Time: 9:44
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>新增课程</title>
    <script src="js/jquery-3.4.1.min.js"></script>
</head>
<body>
<%
    Subject subject=(Subject)request.getAttribute("subject");
%>
 <form method="post" action="updateSubject">
     <fieldset>
         <label>课程信息</label>
         <p>
             编号：<input type="text" name="id" value="<%=subject.getId()%>" readonly/>
             课程名：<input type="text" required name="subjectname" placeholder="课程名" value="<%=subject.getSubjectname()%>"/>
            学时 <input type="number" min="0" required name="classhour" placeholder="学时" value="<%=subject.getClasshour()%>"/>
            所属年级： <select name="gradeid">
                 <%
                     List<Grade> list=(List<Grade>)request.getAttribute("grades");
                     for(Grade g:list){

                 %>
                 <option value="<%=g.getId()%>"
                        <%-- <% if(subject.getGradeId()==g.getId())
                     out.print("selected");%>--%>
                 ><%=g.getGname()%></option>
                 <%}%>
             </select>
         </p>
         <p>
             <input type="submit" value="保存"/>
             <input type="button" value="返回" onclick="javascript:history.back();"/>
         </p>
     </fieldset>
 </form>
<script>
    $(function () {
        $("select[name=gradeid]").val('<%=subject.getGradeId()%>');
    });
</script>
</body>
</html>
